package com.shh.aiojbackendserver.demo;

import jakarta.annotation.Resource;
import org.springframework.ai.chat.messages.AssistantMessage;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.chat.prompt.Prompt;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * springai框架调用ai大模型
 * implements CommandLineRunner 可以在运行时执行
 */
@Component
@Deprecated
public class SpringAIinvoke{

    //根据需要引入相应的大模型
    @Resource
    private ChatModel  dashscopeChatModel;


    public void run(String... args) throws Exception {
        AssistantMessage assistantMessage = dashscopeChatModel.call(new Prompt("你好，我是嗜好"))
                .getResult()
                .getOutput();
        System.out.println(assistantMessage.getText());
    }
}
